package com.atguigu.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.atguigu.entity.Admin;
import com.atguigu.entity.Permission;
import com.atguigu.service.AdminService;
import com.atguigu.service.PermissionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {

    @Reference
    private AdminService adminService;

    @Reference
    private PermissionService permissionService;

    @RequestMapping
    public String index(ModelMap model){
        Long adminId = 10L;
        //查询当前用户的信息
        Admin admin = this.adminService.getById(adminId);
        model.addAttribute("admin",admin);
        //查询当前用户的动态权限菜单
        List<Permission> permissionList = this.permissionService.findMenuPermissionByAdminId(adminId);
        model.addAttribute("permissionList",permissionList);
        return "frame/index";
    }
    @RequestMapping("/main")
    public String main(){
        return "frame/main";
    }
}
